package org.beehoo.web.framework.dao;

import java.io.Serializable;
import java.util.UUID;

import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.id.IdentifierGenerator;

public class AutoId implements IdentifierGenerator {

	private static AutoId idGenerator = new AutoId();

	public AutoId() {
	}

	public static AutoId getInstance() {
		return idGenerator;
	}

	/**
	 * 
	 * 生成32位随即字符串
	 * 
	 * @return
	 * @author duxb
	 * @created 2010-10-11 上午10:12:44
	 */
	public String generateID() {
		return UUID.randomUUID().toString().replace("-", "");
	}

	/**
	 * {该处请说明该method的含义和作用}
	 * 
	 * @param session
	 * @param object
	 * @return
	 * @throws HibernateException
	 * @author duxb
	 * @created 2011-1-26 下午12:26:45
	 */
	public Serializable generate(SessionImplementor session, Object object) throws HibernateException {
		return generateID();
	}
}
